import * as types from "../types/homeTypes";

const initialState = {
  banners: [],
  loading: false,
  initing: true,
  error: undefined,
  brandId: 1,
  hotTags: [],
  hotInfoList: [],
};

export default function homeReducer(state = initialState, action) {
  switch (action.type) {
    case types.HOME_BANNER_INITING:
      return {
        ...state,
        initing: true,
      };
    case types.HOME_BANNER_DONE:
      return {
        ...state,
        initing: false,
        loading: false,
        banners: action.banners,
      };
    case types.HOME_BANNER_ERROR:
      return {
        ...state,
        initing: false,
        loading: false,
        error: action.error,
      };
    case types.HOTTAGS_DONE:
      return {
        ...state,
        hotTags: action.hotTags,
      };
    case types.HOTLIST_DONE:
      return {
        ...state,
        hotInfoList: action.hotInfoList,
      };
    case types.HOTLIST_CHANGETAG:
      return {
        ...state,
        brandId: action.brandId,
      };
    default:
      return state;
  }
}
